Socket
Socket
Sign inDemoInstall

prosemirror-transform

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-transform

ProseMirror document transformations


Version published
Weekly downloads
1.6M
decreased by-0.8%
Maintainers
1
Weekly downloads
 
Created

What is prosemirror-transform?

The prosemirror-transform package is a part of the ProseMirror toolkit, which provides a set of tools for building rich-text editors. This package specifically deals with transforming ProseMirror documents, allowing you to apply changes, manipulate document structure, and handle collaborative editing scenarios.

What are prosemirror-transform's main functionalities?

Applying Steps

This feature allows you to apply a step to a ProseMirror document. Steps are atomic changes that can be applied to a document, such as inserting or deleting content.

const { Step } = require('prosemirror-transform');
const { Schema, DOMParser } = require('prosemirror-model');
const { schema } = require('prosemirror-schema-basic');

let doc = DOMParser.fromSchema(schema).parse(document.querySelector('#content'));
let step = new Step();
let result = step.apply(doc);
console.log(result.doc);

Transformations

This feature allows you to create a transformation and apply multiple changes to a document. Transformations can include inserting, deleting, or replacing content.

const { Transform } = require('prosemirror-transform');
const { Schema, DOMParser } = require('prosemirror-model');
const { schema } = require('prosemirror-schema-basic');

let doc = DOMParser.fromSchema(schema).parse(document.querySelector('#content'));
let tr = new Transform(doc);
tr.insert(1, schema.text('Hello, world!'));
console.log(tr.doc);

Mapping Positions

This feature allows you to map positions in a document, which is useful for collaborative editing where multiple users are making changes simultaneously. The Mapping class helps keep track of position changes.

const { Mapping } = require('prosemirror-transform');

let mapping = new Mapping();
mapping.appendMap({ map: [0, 1, 2, 3] });
let newPos = mapping.map(2);
console.log(newPos);

Other packages similar to prosemirror-transform

FAQs

Package last updated on 16 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc